package org.sakai.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 一般是Service的统一返回结果
 * @param <T>
 */
@Data
@AllArgsConstructor
public class Result<T> {
    @Schema(description = "是否成功")
    private boolean isSuccess;
    @Schema(description = "错误码")
    private ErrorCode errorCode;
    @Schema(description = "数据")
    private T data;
    public static <T> Result<T> success(T data){
        return new Result<T>(true, null, data);
    }
    public static <T> Result<T> error(ErrorCode errorCode){
        return new Result<>(false, errorCode, null);
    }
}
